package com.yztctech.a25_04_aidlserver;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.annotation.Nullable;
import android.text.TextUtils;

/**
 * Created by bodhixu on 2016/9/24.
 * 这里用到onBind()说明client使用的BindService()方法,启动service,那么client就能跨线程持有LoginService了
 */
public class LoginService extends Service{

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {

        return new MyBinder();
    }
		//注意MyBinder是Stub的子类,继承Stub的属性
    class MyBinder extends ILoginListener.Stub{

        @Override
        public boolean login(String name, String psw) throws RemoteException {
            //接收客户端的调用的;微信的三方登陆也是这么处理的呢
            if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(psw)
                    && name.equals("abc") && psw.equals("123")) {
                return true;
            }
            return false;
        }
    }

}
